/*****************************************************
 * PS5 SDK - Libc
 * Contains declarations and init for libc.
 ****************************************************/

#ifndef PS5SDK_LIBC_H
#define PS5SDK_LIBC_H

#include <ps5/dlsym.h>

#ifndef CRT_BUILD
#include <stdio.h>
#endif // CRT_BUILD

int libc_init();

//_Data_    (int, __isthreaded);

_Fn_(int        , atexit,           void (*)(void));
_Fn_(int        , abs,              int);
_Fn_(char *     , asctime,          const struct tm *);
_Fn_(int        , atoi,             const char *);
_Fn_(long       , atol,             const char *);
_Fn_(long long  , atoll,            const char *);
_Fn_(void *     , bsearch,          const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
_Fn_(uint64_t   , btowc,            void);
_Fn_(uint64_t   , c16rtomb,         void);
_Fn_(uint64_t   , c32rtomb,         void);
_Fn_(char *     , ctime,            const time_t *);
_Fn_(uint64_t   , asctime_s,        void);
_Fn_(uint64_t   , bsearch_s,        void);
_Fn_(uint64_t   , ctime_s,          void);
_Fn_(uint64_t   , fopen_s,          void);
_Fn_(uint64_t   , fprintf_s,        void);
_Fn_(uint64_t   , freopen_s,        void);
_Fn_(uint64_t   , fscanf_s,         void);
_Fn_(uint64_t   , fwprintf_s,       void);
_Fn_(uint64_t   , fwscanf_s,        void);
_Fn_(uint64_t   , gets_s,           void);
_Fn_(uint64_t   , gmtime_s,         void);
_Fn_(uint64_t   , localtime_s,      void);
_Fn_(uint64_t   , mbsrtowcs_s,      void);
_Fn_(uint64_t   , mbstowcs_s,       void);
_Fn_(uint64_t   , memset_s,         void);
_Fn_(uint64_t   , printf_s,         void);
_Fn_(uint64_t   , qsort_s,          void);
_Fn_(uint64_t   , scanf_s,          void);
_Fn_(uint64_t   , snprintf_s,       void);
_Fn_(uint64_t   , snwprintf_s,      void);
_Fn_(uint64_t   , sprintf_s,        void);
_Fn_(uint64_t   , sscanf_s,         void);
_Fn_(uint64_t   , strcat_s,         void);
_Fn_(uint64_t   , strcpy_s,         void);
_Fn_(uint64_t   , strerrorlen_s,    void);
_Fn_(uint64_t   , strerror_s,       void);
_Fn_(uint64_t   , strncat_s,        void);
_Fn_(uint64_t   , strncpy_s,        void);
_Fn_(uint64_t   , strtok_s,         void);
_Fn_(uint64_t   , swprintf_s,       void);
_Fn_(uint64_t   , swscanf_s,        void);
_Fn_(uint64_t   , vfprintf_s,       void);
_Fn_(uint64_t   , vfscanf_s,        void);
_Fn_(uint64_t   , vfwprintf_s,      void);
_Fn_(uint64_t   , vfwscanf_s,       void);
_Fn_(uint64_t   , vprintf_s,        void);
_Fn_(uint64_t   , vscanf_s,         void);
_Fn_(uint64_t   , vsnprintf_s,      void);
_Fn_(uint64_t   , vsnwprintf_s,     void);
_Fn_(uint64_t   , vsprintf_s,       void);
_Fn_(uint64_t   , vsscanf_s,        void);
_Fn_(uint64_t   , vswprintf_s,      void);
_Fn_(uint64_t   , vswscanf_s,       void);
_Fn_(uint64_t   , vwprintf_s,       void);
_Fn_(uint64_t   , vwscanf_s,        void);
_Fn_(uint64_t   , wcrtomb_s,        void);
_Fn_(uint64_t   , wcscat_s,         void);
_Fn_(uint64_t   , wcscpy_s,         void);
_Fn_(uint64_t   , wcsncat_s,        void);
_Fn_(uint64_t   , wcsncpy_s,        void);
_Fn_(uint64_t   , wcsnlen_s,        void);
_Fn_(uint64_t   , wcsrtombs_s,      void);
_Fn_(uint64_t   , wcstok_s,         void);
_Fn_(uint64_t   , wcstombs_s,       void);
_Fn_(uint64_t   , wctomb_s,         void);
_Fn_(uint64_t   , wprintf_s,        void);
_Fn_(uint64_t   , wscanf_s,         void);
_Fn_(double     , difftime,         time_t, time_t);
_Fn_(uint64_t   , xtime_get,        void);
_Fn_(double     , drand48,          void);
_Fn_(double     , erand48,          uint16_t[3]);
_Fn_(long       , jrand48,          uint16_t[3]);
_Fn_(void       , lcong48,          uint16_t[7]);
_Fn_(long       , lrand48,          void);
_Fn_(long       , mrand48,          void);
_Fn_(long       , nrand48,          uint16_t[3]);
_Fn_(uint16_t*  , seed48,           uint16_t[3]);
_Fn_(void       , srand48,          long);
_Fn_(int        , fclose,           FILE *);
_Fn_(void       , fcloseall,        void);
_Fn_(int        , fflush,           FILE *);
_Fn_(void       , free,             void *);
#ifndef feof
_Fn_(int        , feof,             FILE *);
#endif
#ifndef feof_unlocked
_Fn_(uint64_t   , feof_unlocked,    void);
#endif
_Fn_(void       , flockfile,        FILE *);
_Fn_(int        , ftrylockfile,     FILE *);
_Fn_(void       , funlockfile,      FILE *);
#ifndef ferror
_Fn_(int        , ferror,           FILE *);
#endif
#ifndef ferror_unlocked
_Fn_(uint64_t   , ferror_unlocked,  void);
#endif
_Fn_(int        , fpurge,           FILE *);
_Fn_(int        , fgetc,            FILE *);
#ifndef getc_unlocked
_Fn_(uint64_t   , getc_unlocked,    void);
#endif
#ifndef getchar_unlocked
_Fn_(uint64_t   , getchar_unlocked, void);
#endif
_Fn_(int        , fgetpos,          FILE * __restrict, fpos_t * __restrict);
_Fn_(char *     , fgets,            char * __restrict, int, FILE * __restrict);
_Fn_(uint64_t   , fgetwc,           void);
_Fn_(uint64_t   , fgetws,           void);
_Fn_(FILE *     , fopen,            const char * __restrict, const char * __restrict);
_Fn_(int        , fprintf,          FILE * __restrict, const char * __restrict, ...);
_Fn_(int        , fputc, int,       FILE *);
#ifndef putc_unlocked
_Fn_(uint64_t   , putc_unlocked,    void);
#endif
#ifndef putchar_unlocked
_Fn_(uint64_t   , putchar_unlocked, void);
#endif
_Fn_(int        , fputs,            const char * __restrict, FILE * __restrict);
_Fn_(uint64_t   , fputwc,           void);
_Fn_(uint64_t   , fputws,           void);
_Fn_(size_t     , fread,            void * __restrict, size_t, size_t, FILE * __restrict);
_Fn_(FILE *     , freopen,          const char * __restrict, const char * __restrict, FILE * __restrict);
_Fn_(int        , fscanf,           FILE * __restrict, const char * __restrict, ...);
_Fn_(int        , fseek,            FILE *, long, int);
_Fn_(int        , fseeko,           FILE *, __off_t, int);
_Fn_(int        , fsetpos,          FILE *, const fpos_t *);
_Fn_(long       , ftell,            FILE *);
_Fn_(__off_t    , ftello,           FILE *);
_Fn_(uint64_t   , fwide,            void);
_Fn_(uint64_t   , fwprintf,         void);
_Fn_(size_t     , fwrite,           const void * __restrict, size_t, size_t, FILE * __restrict);
_Fn_(uint64_t   , fwscanf,          void);
#ifndef getc
_Fn_(int        , getc,             FILE *);
#endif
#ifndef getchar
_Fn_(uint64_t   , getchar,          void);
#endif
_Fn_(char *     , gets,             char *);
_Fn_(int        , getw,             FILE *);
_Fn_(uint64_t   , getwc,            void);
_Fn_(uint64_t   , getwchar,         void);
_Fn_(struct tm *, gmtime,           const time_t *);

_Fn_(int        , imaxabs,          int);
_Fn_(int        , imaxdiv,          int);
_Fn_(int        , isalnum,          int);
_Fn_(int        , isalpha,          int);
_Fn_(int        , isblank,          int);
_Fn_(int        , iscntrl,          int);
_Fn_(int        , isdigit,          int);
_Fn_(int        , isgraph,          int);
_Fn_(int        , islower,          int);
_Fn_(int        , isprint,          int);
_Fn_(int        , ispunct,          int);
_Fn_(int        , isspace,          int);
_Fn_(int        , isupper,          int);
_Fn_(int        , iswalnum,         int);
_Fn_(int        , iswalpha,         int);
_Fn_(int        , iswblank,         int);
_Fn_(int        , iswcntrl,         int);
_Fn_(int        , iswctype,         int);
_Fn_(int        , iswdigit,         int);
_Fn_(int        , iswgraph,         int);
_Fn_(int        , iswlower,         int);
_Fn_(int        , iswprint,         int);
_Fn_(int        , iswpunct,         int);
_Fn_(int        , iswspace,         int);
_Fn_(int        , iswupper,         int);
_Fn_(int        , iswxdigit,        int);
_Fn_(int        , isxdigit,         int);

_Fn_(long       , labs,             long);
_Fn_(long long  , llabs,            long long);

struct lconv;
_Fn_(struct lconv* , localeconv,    void);      // this is NOT in ^ headers!
_Fn_(struct tm *, localtime,        const time_t *);
_Fn_(int        , mblen,            const char *, size_t);
_Fn_(uint64_t   , mbrlen,           void);
_Fn_(uint64_t   , mbrtoc16,         void);
_Fn_(uint64_t   , mbrtoc32,         void);
_Fn_(uint64_t   , mbrtowc,          void);
_Fn_(uint64_t   , mbsinit,          void);
_Fn_(uint64_t   , mbsrtowcs,        void);
_Fn_(size_t     , mbstowcs,         wchar_t * __restrict, const char * __restrict, size_t);
_Fn_(int        , mbtowc,           wchar_t * __restrict, const char * __restrict, size_t);
_Fn_(time_t     , mktime,           struct tm *);
_Fn_(void       , perror,           const char *);
_Fn_(int        , printf,           const char * __restrict, ...);
#ifndef putc
_Fn_(int        , putc,             int, FILE *);
#endif
#ifndef putchar
_Fn_(uint64_t   , putchar,          void);
#endif
_Fn_(int        , puts,             const char *);
_Fn_(int        , putw,             int, FILE *);
_Fn_(uint64_t   , putwc,            void);
_Fn_(uint64_t   , putwchar,         void);
_Fn_(void       , qsort,            void *, size_t, size_t, int (*)(const void *, const void *));
_Fn_(void       , rewind,           FILE *);
_Fn_(int        , scanf,            const char * __restrict, ...);
_Fn_(void       , setbuf,           FILE * __restrict, char * __restrict);
_Fn_(char *     , setlocale,        int, const char *);
_Fn_(int        , setvbuf,          FILE * __restrict, char * __restrict, int, size_t);
_Fn_(void *     , memcpy,           void *, const void *, size_t);
_Fn_(int        , sscanf,           const char * __restrict, const char * __restrict, ...);
_Fn_(int        , strcoll,          const char *, const char *);
_Fn_(char *     , strerror,         int);
_Fn_(int        , strerror_r,       int, char *, size_t);
_Fn_(size_t     , strftime,         char * __restrict, size_t, const char * __restrict, const struct tm * __restrict);
_Fn_(uint64_t   , strncat,          void);
_Fn_(const char*, strpbrk,          const char *, const char *);
_Fn_(char *     , strstr,           const char *, const char *);
_Fn_(uint64_t   , strtoimax,        void);
_Fn_(uint64_t   , strtok,           void);
_Fn_(long               , strtol,   const char * __restrict, char ** __restrict, int);
_Fn_(long double        , strtold,  const char * __restrict, char ** __restrict);
_Fn_(long long          , strtoll,  const char * __restrict, char ** __restrict, int);
_Fn_(unsigned long      , strtoul,  const char * __restrict, char ** __restrict, int);
_Fn_(unsigned long long , strtoull, const char * __restrict, char ** __restrict, int);
_Fn_(uint64_t   , strtoumax,        void);
_Fn_(uint64_t   , strxfrm,          void);
_Fn_(uint64_t   , swprintf,         void);
_Fn_(uint64_t   , swscanf,          void);
_Fn_(int        , tolower,          int);
_Fn_(int        , toupper,          int);
_Fn_(uint64_t   , towctrans,        void);
_Fn_(uint64_t   , towlower,         void);
_Fn_(uint64_t   , towupper,         void);
_Fn_(uint64_t   , daylight,         void);
_Fn_(char *     , timezone,         int, int);
_Data_(char *   , tzname[]);
_Fn_(void       , tzset,            void);
_Fn_(int        , ungetc,           int, FILE *);
_Fn_(uint64_t   , ungetwc,          void);
_Fn_(int        , vfprintf,         FILE * __restrict, const char * __restrict,__va_list);
_Fn_(int        , vfscanf,          FILE * __restrict, const char * __restrict, __va_list);
_Fn_(uint64_t   , vfwprintf,        void);
_Fn_(uint64_t   , vfwscanf,         void);
_Fn_(int        , vprintf,          const char * __restrict, __va_list);
_Fn_(int        , vscanf,           const char * __restrict, __va_list);
_Fn_(int        , vsnprintf,        char * __restrict, size_t, const char * __restrict, __va_list);
_Fn_(int        , vsprintf,         char * __restrict, const char * __restrict, __va_list);
_Fn_(int        , vsscanf,          const char * __restrict, const char * __restrict, __va_list);
_Fn_(uint64_t   , vswprintf,        void);
_Fn_(uint64_t   , vswscanf,         void);
_Fn_(uint64_t   , vwprintf,         void);
_Fn_(uint64_t   , vwscanf,          void);
_Fn_(uint64_t   , wcrtomb,          void);
_Fn_(uint64_t   , wcscat,           void);
_Fn_(uint64_t   , wcschr,           void);
_Fn_(uint64_t   , wcscmp,           void);
_Fn_(uint64_t   , wcscoll,          void);
_Fn_(uint64_t   , wcscpy,           void);
_Fn_(uint64_t   , wcscspn,          void);
_Fn_(uint64_t   , wcsftime,         void);
_Fn_(uint64_t   , wcslen,           void);
_Fn_(uint64_t   , wcsncat,          void);
_Fn_(uint64_t   , wcsncmp,          void);
_Fn_(uint64_t   , wcsncpy,          void);
_Fn_(uint64_t   , wcspbrk,          void);
_Fn_(uint64_t   , wcsrchr,          void);
_Fn_(uint64_t   , wcsrtombs,        void);
_Fn_(uint64_t   , wcsspn,           void);
_Fn_(uint64_t   , wcsstr,           void);
_Fn_(uint64_t   , wcstoimax,        void);
_Fn_(uint64_t   , wcstok,           void);
_Fn_(uint64_t   , wcstol,           void);
_Fn_(uint64_t   , wcstold,          void);
_Fn_(uint64_t   , wcstoll,          void);
_Fn_(size_t     , wcstombs,         char * __restrict, const wchar_t * __restrict, size_t);
_Fn_(uint64_t   , wcstoul,          void);
_Fn_(uint64_t   , wcstoull,         void);
_Fn_(uint64_t   , wcstoumax,        void);
_Fn_(uint64_t   , wcsxfrm,          void);
_Fn_(uint64_t   , wctob,            void);
_Fn_(int        , wctomb,           char *, wchar_t);
_Fn_(uint64_t   , wctrans,          void);
_Fn_(uint64_t   , wctype,           void);
_Fn_(uint64_t   , wmemchr,          void);
_Fn_(uint64_t   , wmemcmp,          void);
_Fn_(uint64_t   , wprintf,          void);
_Fn_(uint64_t   , wscanf,           void);
_Fn_(void *     , malloc,           size_t);
_Fn_(void *     , memchr,           void *, int, size_t);
_Fn_(char *     , strchr,           const char *, int);
_Fn_(char *     , strcspn,          void);
_Fn_(ldiv_t     , ldiv,             long, long);
_Fn_(div_t      , div,              int, int);
_Fn_(int        , rand,             void);
_Fn_(int        , rand_r,           unsigned *);
_Fn_(void       , srand,            unsigned);
_Fn_(uint64_t   , strcasecmp,       void);
_Fn_(uint64_t   , strdup,           void);
_Fn_(uint64_t   , strncasecmp,      void);
_Fn_(uint64_t   , strtok_r,         void);
_Fn_(char *     , fgetln,           FILE *, size_t *);
_Fn_(uint64_t   , syslog,           void);
_Fn_(uint64_t   , vsyslog,          void);
_Fn_(int        , asprintf,         char **, const char *, ...);
_Fn_(uint64_t   , bcopy,            void);
_Fn_(uint64_t   , memmove,          void);
_Fn_(uint64_t   , memcpy_s,         void);
_Fn_(uint64_t   , memmove_s,        void);
_Fn_(void *     , memset,           void *, int, size_t);
_Fn_(int        , strncmp,          const char*, const char*, size_t);
_Fn_(char *     , strncpy,          char *, const char *, size_t);
_Fn_(size_t     , strnlen_s,        const char *, size_t);
_Fn_(uint64_t   , strrchr,          void);
_Fn_(int        , vasprintf,        char **, const char *, __va_list);
_Fn_(uint64_t   , wmemcpy,          void);
_Fn_(uint64_t   , wmemcpy_s,        void);
_Fn_(uint64_t   , wmemmove,         void);
_Fn_(uint64_t   , wmemmove_s,       void);
_Fn_(uint64_t   , wmemset,          void);
_Fn_(void       , abort,            void);
_Fn_(uint64_t   , abort_handler_s,  void);
_Fn_(uint64_t   , ignore_handler_s, void);
_Fn_(uint64_t   , set_constraint_handler_s,     void);
_Fn_(void *     , calloc,           size_t, size_t);
_Fn_(uint64_t   , sceLibcDebugOut,  void);
#ifndef stderr
_Fn_(uint64_t   , stderr,           void);
#endif
#ifndef stdin
_Fn_(uint64_t   , stdin,            void);
#endif
#ifndef stdout
_Fn_(uint64_t   , stdout,           void);
#endif
_Fn_(uint64_t   , sceLibcOnce,                              void);
_Fn_(uint64_t   , sceLibcHeapGetAddressRanges,              void);
_Fn_(uint64_t   , sceLibcHeapSetAddressRangeCallback,       void);
_Fn_(uint64_t   , sceLibcMspaceGetAddressRanges,            void);
_Fn_(uint64_t   , aligned_alloc,                            void);
_Fn_(uint64_t   , malloc_check_memory_bounds,               void);
_Fn_(uint64_t   , malloc_finalize,                          void);
_Fn_(uint64_t   , malloc_get_footer_value,                  void);
_Fn_(uint64_t   , malloc_get_malloc_state,                  void);
_Fn_(uint64_t   , malloc_initialize,                        void);
_Fn_(uint64_t   , malloc_report_memory_blocks,              void);
_Fn_(uint64_t   , malloc_stats,                             void);
_Fn_(uint64_t   , malloc_stats_fast,                        void);
_Fn_(uint64_t   , malloc_usable_size,                       void);
_Fn_(uint64_t   , memalign,                                 void);
_Fn_(int        , posix_memalign,                           void**, size_t, size_t);
_Fn_(void *     , realloc,                                  void* , size_t);
_Fn_(uint64_t   , reallocalign,                             void);
_Fn_(uint64_t   , sceLibcInternalSetMallocCallback,         void);
_Fn_(uint64_t   , sceLibcMspaceCalloc,                      void);
_Fn_(uint64_t   , sceLibcMspaceFree,                        void);
_Fn_(uint64_t   , sceLibcMspaceMalloc,                      void);
_Fn_(uint64_t   , sceLibcMspaceMallocStats,                 void);
_Fn_(uint64_t   , sceLibcMspaceMallocStatsFast,             void);
_Fn_(uint64_t   , sceLibcMspaceMallocUsableSize,            void);
_Fn_(uint64_t   , sceLibcMspaceMemalign,                    void);
_Fn_(uint64_t   , sceLibcMspacePosixMemalign,               void);
_Fn_(uint64_t   , sceLibcHeapMutexCalloc,                   void);
_Fn_(uint64_t   , sceLibcHeapMutexFree,                     void);
_Fn_(uint64_t   , sceLibcHeapSetTraceMarker,                void);
_Fn_(uint64_t   , sceLibcHeapUnsetTraceMarker,              void);
_Fn_(uint64_t   , sceLibcInternalMemoryGetWakeAddr,         void);
_Fn_(uint64_t   , sceLibcInternalMemoryMutexEnable,         void);
_Fn_(uint64_t   , sceLibcMspaceAlignedAlloc,                void);
_Fn_(uint64_t   , sceLibcMspaceCreate,                      void);
_Fn_(uint64_t   , sceLibcMspaceDestroy,                     void);
_Fn_(uint64_t   , sceLibcMspaceIsHeapEmpty,                 void);
_Fn_(uint64_t   , sceLibcMspaceRealloc,                     void);
_Fn_(uint64_t   , sceLibcMspaceReallocalign,                void);
_Fn_(uint64_t   , sceLibcMspaceSetMallocCallback,           void);
_Fn_(uint64_t   , sceLibcPafMspaceCalloc,                   void);
_Fn_(uint64_t   , sceLibcPafMspaceCheckMemoryBounds,        void);
_Fn_(uint64_t   , sceLibcPafMspaceCreate,                   void);
_Fn_(uint64_t   , sceLibcPafMspaceDestroy,                  void);
_Fn_(uint64_t   , sceLibcPafMspaceFree,                     void);
_Fn_(uint64_t   , sceLibcPafMspaceGetFooterValue,           void);
_Fn_(uint64_t   , sceLibcPafMspaceIsHeapEmpty,              void);
_Fn_(uint64_t   , sceLibcPafMspaceMalloc,                   void);
_Fn_(uint64_t   , sceLibcPafMspaceMallocStats,              void);
_Fn_(uint64_t   , sceLibcPafMspaceMallocStatsFast,          void);
_Fn_(uint64_t   , sceLibcPafMspaceMallocUsableSize,         void);
_Fn_(uint64_t   , sceLibcPafMspaceMemalign,                 void);
_Fn_(uint64_t   , sceLibcPafMspacePosixMemalign,            void);
_Fn_(uint64_t   , sceLibcPafMspaceRealloc,                  void);
_Fn_(uint64_t   , sceLibcPafMspaceReallocalign,             void);
_Fn_(uint64_t   , sceLibcPafMspaceReportMemoryBlocks,       void);
_Fn_(uint64_t   , sceLibcPafMspaceTrim,                     void);
_Fn_(FILE*      , fdopen,           int, const char *);
#ifndef fileno
_Fn_(int        , fileno,           FILE *);
#endif
#ifndef fileno_unlocked
_Fn_(uint64_t   , fileno_unlocked,  void);
#endif
_Fn_(uint64_t   , at_quick_exit,    void);
_Fn_(uint64_t   , quick_exit,       void);
_Fn_(float      , strtof,           const char * __restrict, char ** __restrict);
_Fn_(uint64_t   , wcstof,           void);
_Fn_(int        , remove,           const char *);
_Fn_(uint64_t   , acoshl,           void);
_Fn_(uint64_t   , asinhl,           void);
_Fn_(uint64_t   , atanhl,           void);
_Fn_(uint64_t   , coshl,            void);
_Fn_(uint64_t   , erfcl,            void);
_Fn_(uint64_t   , erfl,             void);
_Fn_(uint64_t   , expl,             void);
_Fn_(uint64_t   , expm1l,           void);
_Fn_(double     , fabs,             double);
_Fn_(uint64_t   , hypot3,           void);
_Fn_(uint64_t   , hypot3f,          void);
_Fn_(uint64_t   , hypot3l,          void);
_Fn_(double     , ldexp,            double, int);
_Fn_(uint64_t   , lgammal,          void);
_Fn_(uint64_t   , log10l,           void);
_Fn_(uint64_t   , log1pl,           void);
_Fn_(uint64_t   , log2l,            void);
_Fn_(uint64_t   , logl,             void);
_Fn_(double     , modf,             double, double *);
_Fn_(double     , nan,              const char *);
_Fn_(float      , nanf,             const char *);
_Fn_(long double, nanl,             const char *);
_Fn_(uint64_t   , powl,             void);
_Fn_(uint64_t   , sinhl,            void);
_Fn_(uint64_t   , tanhl,            void);
_Fn_(uint64_t   , tgammal,          void);
_Fn_(uint64_t   , fegetround,       void);
_Fn_(long double, ldexpl,           long double, int);
_Fn_(long double, sqrtl,            long double);
_Fn_(uint64_t   , feraiseexcept,    void);
_Fn_(float      , atan2f,           float,    float);
_Fn_(float      , atanf,            float);
_Fn_(double     , fma,              double, double,  double);
_Fn_(float      , fmaf,             float, float,   float);
_Fn_(double     , strtod,           const char * __restrict, char ** __restrict);
_Fn_(uint64_t   , wcstod,           void);
_Fn_(uint64_t   , makecontext,      void);
_Fn_(uint64_t   , signalcontext,    void);
_Fn_(int        , sigblock,         int);
_Fn_(int        , sigsetmask,       int);
_Fn_(int        , sigvec,           int, struct sigvec *, struct sigvec *);
_Fn_(uint32_t   , alarm,            uint32_t);
_Fn_(uint64_t   , basename,         void);
_Fn_(uint64_t   , basename_r,       void);
_Fn_(uint64_t   , closedir,         void);
_Fn_(int        , daemon,           int, int);
_Fn_(char *     , devname,          __dev_t, __mode_t);
_Fn_(char *     , devname_r,        __dev_t, __mode_t, char *, int);
_Fn_(uint64_t   , dirname,          void);
_Fn_(uint64_t   , err,              void);
_Fn_(uint64_t   , err_set_exit,     void);
_Fn_(uint64_t   , err_set_file,     void);
_Fn_(uint64_t   , errc,             void);
_Fn_(uint64_t   , errx,             void);
_Fn_(uint64_t   , verr,             void);
_Fn_(uint64_t   , verrc,            void);
_Fn_(uint64_t   , verrx,            void);
_Fn_(uint64_t   , vwarn,            void);
_Fn_(uint64_t   , vwarnc,           void);
_Fn_(uint64_t   , vwarnx,           void);
_Fn_(uint64_t   , warn,             void);
_Fn_(uint64_t   , warnc,            void);
_Fn_(uint64_t   , warnx,            void);
_Fn_(char *     , getcwd,           char *, size_t);
_Fn_(int        , gethostname,      char *, size_t);
_Fn_(uint64_t   , fdopendir,        void);
_Fn_(uint64_t   , opendir,          void);

_Fn_(uint64_t   , posix_spawn,      void);
_Fn_(uint64_t   , posix_spawn_file_actions_addclose,        void);
_Fn_(uint64_t   , posix_spawn_file_actions_adddup2,         void);
_Fn_(uint64_t   , posix_spawn_file_actions_addopen,         void);
_Fn_(uint64_t   , posix_spawn_file_actions_destroy,         void);
_Fn_(uint64_t   , posix_spawn_file_actions_init,            void);
_Fn_(uint64_t   , posix_spawnattr_destroy,                  void);
_Fn_(uint64_t   , posix_spawnattr_getflags,                 void);
_Fn_(uint64_t   , posix_spawnattr_getpgroup,                void);
_Fn_(uint64_t   , posix_spawnattr_getschedparam,            void);
_Fn_(uint64_t   , posix_spawnattr_getschedpolicy,           void);
_Fn_(uint64_t   , posix_spawnattr_getsigdefault,            void);
_Fn_(uint64_t   , posix_spawnattr_getsigmask,               void);
_Fn_(uint64_t   , posix_spawnattr_init,                     void);
_Fn_(uint64_t   , posix_spawnattr_setflags,                 void);
_Fn_(uint64_t   , posix_spawnattr_setpgroup,                void);
_Fn_(uint64_t   , posix_spawnattr_setschedparam,            void);
_Fn_(uint64_t   , posix_spawnattr_setschedpolicy,           void);
_Fn_(uint64_t   , posix_spawnattr_setsigdefault,            void);
_Fn_(uint64_t   , posix_spawnattr_setsigmask,               void);
_Fn_(uint64_t   , posix_spawnp,                             void);

_Fn_(void       , psignal,          unsigned int, const char *);
_Fn_(uint64_t   , readdir,          void);
_Fn_(uint64_t   , readdir_r,        void);
_Fn_(uint64_t   , rewinddir,        void);
_Fn_(uint64_t   , seekdir,          void);
_Fn_(int        , siginterrupt,     int,int);
#if 0
_Fn_(uint64_t   , sys_nsig,         void);
_Fn_(uint64_t   , sys_siglist,      void);
_Fn_(uint64_t   , sys_signame,      void);
#endif
_Fn_(uint64_t   , fstatvfs,         void);
_Fn_(uint64_t   , statvfs,          void);
_Fn_(uint64_t   , telldir,          void);
_Fn_(uint64_t   , utime,            void);
_Fn_(uint64_t   , inet_addr,        void);
_Fn_(uint64_t   , inet_aton,        void);
_Fn_(uint64_t   , inet_ntoa,        void);
_Fn_(uint64_t   , inet_ntoa_r,      void);
_Fn_(uint64_t   , freeifaddrs,      void);
_Fn_(uint64_t   , getifaddrs,       void);
_Fn_(void       , exit,             int);
_Fn_(char *     , getenv,           const char *);
_Fn_(int        , putenv,           char *);
_Fn_(int        , setenv,           const char *, const char *, int);
_Fn_(int        , unsetenv,         const char *);
_Fn_(uint64_t   , getopt_long,      void);
_Fn_(uint64_t   , getopt_long_only, void);
_Fn_(int        , mergesort,        void *, size_t, size_t, int (*)(const void *, const void *));
_Fn_(char *     , initstate,        unsigned long, char *, long);  // maybe u_int
_Fn_(long       , random,           void);
_Fn_(char *     , setstate,         char *);
_Fn_(void       , srandom,          unsigned long);
_Fn_(void       , srandomdev,       void);
_Fn_(void *     , reallocf,         void *, size_t);
_Fn_(char *     , realpath,         const char * __restrict, char * __restrict);
_Fn_(uint64_t   , strtouq,          const char *, char **, int);
_Fn_(uint64_t   , memrchr,          void);
_Fn_(uint64_t   , rindex,           void);
_Fn_(uint64_t   , stpcpy,           void);
_Fn_(uint64_t   , feclearexcept,    void);
_Fn_(uint64_t   , fedisableexcept,  void);
_Fn_(uint64_t   , feenableexcept,   void);
_Fn_(uint64_t   , fegetenv,         void);
_Fn_(uint64_t   , fegetexcept,      void);
_Fn_(uint64_t   , fegetexceptflag,  void);
_Fn_(uint64_t   , fegettrapenable,  void);
_Fn_(uint64_t   , feholdexcept,     void);
_Fn_(uint64_t   , fesetenv,         void);
_Fn_(uint64_t   , fesetexceptflag,  void);
_Fn_(uint64_t   , fesetround,       void);
_Fn_(uint64_t   , fesettrapenable,  void);
_Fn_(uint64_t   , fetestexcept,     void);
_Fn_(uint64_t   , feupdateenv,      void);
_Fn_(double     , tgamma,           double);
_Fn_(long double, exp2l,            long double);
_Fn_(double     , acos,             double);
_Fn_(float      , acosf,            float);
_Fn_(double     , acosh,            double);
_Fn_(float      , acoshf,           float);
_Fn_(long double, acosl,            long double);
_Fn_(double     , asin,             double);
_Fn_(float      , asinf,            float);
_Fn_(long double, asinl,            long double);
_Fn_(double     , atan2,            double, double);
_Fn_(long double, atan2l,           long double,    long double);
_Fn_(double     , atanh,            double);
_Fn_(float      , atanhf,           float);
_Fn_(double     , cosh,             double);
_Fn_(float      , coshf,            float);
_Fn_(double     , exp,              double);
_Fn_(float      , expf,             float);
_Fn_(double     , fmod,             double, double);
_Fn_(float      , fmodf,            float,  float);
_Fn_(long double, fmodl,            long double,    long double);
_Fn_(double     , gamma,            double);
_Fn_(float      , gammaf,           float);
_Fn_(float      , gammaf_r,         float, int *);
_Fn_(double     , gamma_r,          double,int *);
_Fn_(double     , hypot,            double,    double);
_Fn_(float      , hypotf,           float,  float);
_Fn_(long double, hypotl,           long double,  long double);
_Fn_(double     , j0,               double);
_Fn_(double     , y0,               double);
_Fn_(float      , j0f,              float);
_Fn_(float      , y0f,              float);
_Fn_(double     , j1,               double);
_Fn_(double     , y1,               double);
_Fn_(float      , j1f,              float);
_Fn_(float      , y1f,              float);
_Fn_(double     , jn,               int,  double);
_Fn_(double     , yn,               int,  double);
_Fn_(float      , jnf,              int, float);
_Fn_(float      , ynf,              int, float);
_Fn_(double     , lgamma,           double);
_Fn_(float      , lgammaf,          float);
_Fn_(float      , lgammaf_r,        float, int *);
_Fn_(double     , lgamma_r,         double,int *);
_Fn_(double     , log,              double);
_Fn_(double     , log10,            double);
_Fn_(float      , log10f,           float);
_Fn_(double     , log2,             double);
_Fn_(float      , log2f,            float);
_Fn_(float      , logf,             float);
_Fn_(double     , pow,              double, double);
_Fn_(float      , powf,             float,  float);
_Fn_(double     , scalb,            double, double);
_Fn_(float      , scalbf,           float,  float);
_Fn_(double     , sinh,             double);
_Fn_(float      , sinhf,            float);
_Fn_(double     , remainder,        double, double);
_Fn_(float      , remainderf,       float,  float);
_Fn_(long double, remainderl,       long double,    long double);
_Fn_(double     , remquo,           double, double, int *);
_Fn_(float      , remquof,          float,  float,  int *);
_Fn_(long double, remquol,          long double, long double, int *);
_Fn_(double     , sqrt,             double);
_Fn_(float      , sqrtf,            float);
_Fn_(double     , asinh,            double);
_Fn_(float      , asinhf,           float);
_Fn_(double     , atan,             double);
_Fn_(long double, atanl,            long double);
_Fn_(double     , cbrt,             double);
_Fn_(float      , cbrtf,            float);
_Fn_(long double, cbrtl,            long double);
_Fn_(double     , ceil,             double);
_Fn_(float      , ceilf,            float);
_Fn_(long double, ceill,            long double);
_Fn_(double     , copysign,         double, double);
_Fn_(float      , copysignf,        float,  float);
_Fn_(long double, copysignl,        long double,   long double);
_Fn_(double     , cos,              double);
_Fn_(float      , cosf,             float);
_Fn_(long double, cosl,             long double);
_Fn_(double     , erf,              double);
_Fn_(double     , erfc,             double);
_Fn_(float      , erfcf,            float);
_Fn_(float      , erff,             float);
_Fn_(double     , exp2,             double);
_Fn_(float      , exp2f,            float);
_Fn_(double     , expm1,            double);
_Fn_(float      , expm1f,           float);
_Fn_(float      , fabsf,            float);
_Fn_(long double, fabsl,            long double);
_Fn_(double     , fdim,             double, double);
_Fn_(float      , fdimf,            float,  float);
_Fn_(long double, fdiml,            long double,   long double);
_Fn_(int        , finite,           double);
_Fn_(int        , finitef,          float);
_Fn_(double     , floor,            double);
_Fn_(float      , floorf,           float);
_Fn_(long double, floorl,           long double);
_Fn_(long double, fmal,             long double, long double,   long double);
_Fn_(double     , fmax,             double, double);
_Fn_(float      , fmaxf,            float,  float);
_Fn_(long double, fmaxl,            long double,   long double);
_Fn_(double     , fmin,             double, double);
_Fn_(float      , fminf,            float,  float);
_Fn_(long double, fminl,            long double,   long double);
_Fn_(double     , frexp,            double, int*);
_Fn_(float      , frexpf,           float,  int*);
_Fn_(long double, frexpl,           long double, int*);
_Fn_(int        , ilogb,            double);
_Fn_(int        , ilogbf,           float);
_Fn_(int        , ilogbl,           long double);
#ifndef isnan
_Fn_(int        , isnan,            double);
#endif
_Fn_(int        , isnanf,           float);
_Fn_(long long  , llround,          double);
_Fn_(long long  , llroundl,         long double);
_Fn_(double     , log1p,            double);
_Fn_(float      , log1pf,           float);
_Fn_(double     , logb,             double);
_Fn_(float      , logbf,            float);
_Fn_(long       , lround,           double);
_Fn_(long       , lroundf,          float);
_Fn_(long       , lroundl,          long double);
_Fn_(float      , modff,            float, float *);
_Fn_(long double, modfl,            long double, long double *);
_Fn_(double     , nearbyint,        double);
_Fn_(float      , nearbyintf,       float);
_Fn_(long double, nearbyintl,       long double);
_Fn_(double     , nextafter,        double, double);
_Fn_(float      , nextafterf,       float, float);
_Fn_(long double, nextafterl,       long double,  long double);
_Fn_(long double, nexttowardl,      long double, long double);
_Fn_(double     , nexttoward,       double,   long double);
_Fn_(float      , nexttowardf,      float,  long double);
_Fn_(double     , rint,             double);
_Fn_(float      , rintf,            float);
_Fn_(double     , round,            double);
_Fn_(float      , roundf,           float);
_Fn_(long double, roundl,           long double);
_Fn_(double     , scalbln,          double, long);
_Fn_(float      , scalblnf,         float,  long);
_Fn_(long double, scalblnl,         long double, long);
_Data_(int      , signgam);
_Fn_(double     , significand,      double);
_Fn_(float      , significandf,     float);
_Fn_(double     , sin,              double);
_Fn_(double     , sincos,           double);
_Fn_(float      , sincosf,          float);
_Fn_(float      , sinf,             float);
_Fn_(long double, sinl,             long double);
_Fn_(double     , tan,              double);
_Fn_(float      , tanf,             float);
_Fn_(double     , tanh,             double);
_Fn_(float      , tanhf,            float);
_Fn_(long double, tanl,             long double);
_Fn_(float      , tgammaf,          float);
_Fn_(double     , trunc,            double);
_Fn_(float      , truncf,           float);
_Fn_(long double, truncl,           long double);
_Fn_(double     , drem,             double, double);
_Fn_(float      , dremf,            float,  float);
_Fn_(long long  , llrint,           double);
_Fn_(long long  , llrintf,          float);
_Fn_(long long  , llrintl,          long double);
_Fn_(long double, logbl,            long double);
_Fn_(long       , lrint,            double);
_Fn_(long       , lrintf,           float);
_Fn_(long       , lrintl,           long double);
_Fn_(long double, rintl,            long double);
_Fn_(double     , scalbn,           double, int);
_Fn_(float      , ldexpf,           float,  int);
_Fn_(float      , scalbnf,          float,  int);
_Fn_(long double, scalbnl,          long double, int);
_Fn_(int        , memcmp,           const void *, const void *, size_t);
_Fn_(int        , strcmp,           const char *, const char *);
_Fn_(uint64_t   , clock_1700,       void);
_Fn_(clock_t    , clock,            void);
_Fn_(const char *,getprogname,      void);
#ifndef isinf
_Fn_(uint64_t   , isinf,            void);
#endif
_Fn_(time_t     , time,             time_t *);
_Fn_(double     , atof,             const char *);
_Fn_(int        , getopt,           int, char * const [], const char *);

_Data_(char*    , optarg);
_Data_(int      , opterr);
_Data_(int      , optind);
_Data_(int      , optopt);
_Data_(int      , optreset);

_Fn_(uint64_t   , flsl,             void);
_Fn_(uint64_t   , index,            void);
_Fn_(uint64_t   , strlcat,          void);
_Fn_(uint64_t   , strlcpy,          void);
_Fn_(uint64_t   , strndup,          void);
_Fn_(uint64_t   , strnlen,          void);
_Fn_(uint64_t   , strnstr,          void);
_Fn_(uint64_t   , strsep,           void);
_Fn_(size_t     , strspn,           const char *, const char *);

_Fn_(size_t     , strlen,           const char *s);

_Fn_(int        , sprintf,          char * __restrict,         const char * __restrict,...);
_Fn_(int        , snprintf,         char * __restrict, size_t, const char * __restrict,...);


// *TODO* test !
_Fn_(void       , __longjmp,        jmp_buf, int);
_Fn_(void       , longjmp,          jmp_buf, int);
_Fn_(int        , setjmp,           jmp_buf);

#if __HAVE_STDLIB
_Fn_(lldiv_t    , lldiv,            long long, long long);
#endif

_Fn_(uint64_t   , bcmp,             void);
_Fn_(uint64_t   , bzero,            void);
_Fn_(uint64_t   , strcat,           void);
_Fn_(char *     , strcpy,           char *, const char *);

#endif // PS5SDK_LIBC_H
